<div id="cal" style="float:left"></div>
	
<script type="text/javascript">

enabled = { <?	$yr = array();
	foreach (dat('days') as $y => $ms) { $mr = array();
		foreach ($ms as $m => $ds)
			$mr[] = "$m : { ".implode(' : 1, ', array_keys($ds))." : 1 }";
		$yr[] = "$y : { ".implode(', ', $mr)." }";
	} ?>
	<?=implode(', ', $yr)?>
};

Calendar.setup({
	flat         : "cal", // ID of the parent element
	flatCallback : function (cal) { 
		var temp;
		if (cal.dateClicked) {
			var y = cal.date.getFullYear();
			var m = cal.date.getMonth();     // integer, 0..11
			var d = ((temp = cal.date.getDate()) > 9) ? temp : "0" + temp;      // integer, 1..31
			// redirect...
			location.href = y + "-" + (m + 1) + "-" + d + "/";
		 }
		return true;
	},
	firstDay	:	1,
	dateStatusFunc : function(date, y, m, d) { return enabled[y] && enabled[y][m+1] && enabled[y][m+1][d] && "enabled" }
	
});
</script>
